package com.zz.ecommerce.common.provider;

/**
 * Created by Administrator on 2015/8/17.
 */
public class PageProvider
{
    public String page(String sql)
    {
        StringBuilder builder = new StringBuilder();
        builder.append("SELECT * FROM");
        builder.append("(");
        builder.append("    SELECT A. *, ROWNUM RN");
        builder.append("    FROM(");

        builder.append(sql);

        builder.append("     ) A");
        builder.append("    WHERE ROWNUM <= #{request.end}");
        builder.append(")");
        builder.append("WHERE RN >= #{request.start}");

        return builder.toString();
    }
}
